package at.ac.univie.zsu.aguataplan.main;

import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import at.ac.univie.zsu.aguataplan.util.Constants;
import at.ac.univie.zsu.aguataplan.util.EnvironmentHandler;
import at.ac.univie.zsu.aguataplan.util.InitLogger;

public class Main implements Constants {
	private static Logger log = Logger.getLogger(Main.class);

	private static ApplicationContext context;

	// ----------------------------------------------------
	// MAIN
	// ----------------------------------------------------
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		InitLogger.initLogger();
		EnvironmentHandler.readArgs(args);

		log.info("AGUATAPLAN started...");

		// ApplicationContext context = new FileSystemXmlApplicationContext(
		// "C:\\Users\\bw\\Documents\\workspace-sts-2.7.1.RELEASE\\Aguataplan\\src\\main\\resources\\META-INF\\spring\\applicationContext.xml");

		// context = new FileSystemXmlApplicationContext(
		// "C:\\Users\\bw\\Documents\\workspace-sts-2.7.1.RELEASE\\Aguataplan\\src\\main\\resources\\META-INF\\spring\\applicationContext.xml");
		context = new ClassPathXmlApplicationContext("META-INF/spring/applicationContext.xml");
		// -------------------------------------

		// ApplicationContext context = new
		// ClassPathXmlApplicationContext("META-INF/spring/applicationContext.xml");

		// Ranking r = (Ranking) context.getBean("aaa");
		//
		// r.setDescription("superranking");
		// r.persist();
		//
		// Ranking rr = new Ranking();
		//
		// rr.setDescription("asdf");
		// rr.persist();

		// SystemProperties s = (SystemProperties)
		// context.getBean("systemPropertiesId");
		// System.out.println(s.getFtpServerAddress());

		// DatabaseProperties p = (DatabaseProperties)
		// context.getBean("databasePropertiesId");
		// System.out.println(p.getDriverClassName());

		// TestBean tb = (TestBean) context.getBean("tb");
		// tb.getI18nn();
		// System.out.println(tb.getI18nn().getString("fileMenu"));

	}

	// ----------------------------------------------------
	// METHODS
	// ----------------------------------------------------

	public static ApplicationContext getContext() {
		return context;
	}

}
